<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#one" data-toggle="tab">排程冲突检测</a></li>
        </ul>
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="刷新"><i class="fa fa-refresh"></i></a>
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover" width="100%">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        var options = {
            url: $.fn.bootstrapTable.defaults.extend.index_url,
            pk: 'id',
            sortName: 'severity',
            sortOrder: 'desc',
            columns: [
                [
                    {checkbox: true},
                    {field: 'id', title: 'ID'},
                    {field: 'task_no_1', title: '任务1'},
                    {field: 'task_no_2', title: '任务2'},
                    {field: 'conflict_type', title: '冲突类型', searchList: {1:'资源冲突',2:'时间冲突',3:'物料冲突',4:'依赖冲突'}, formatter: Table.api.formatter.normal},
                    {field: 'severity', title: '严重程度', formatter: function(value) {
                        var levels = {1: 'danger', 2: 'warning', 3: 'info'};
                        var texts = {1: '高', 2: '中', 3: '低'};
                        return '<span class="label label-' + levels[value] + '">' + texts[value] + '</span>';
                    }},
                    {field: 'conflict_description', title: '冲突描述'},
                    {field: 'suggest_solution', title: '建议解决方案'},
                    {field: 'is_resolved', title: '是否已解决', searchList: {0:'未解决',1:'已解决'}, formatter: Table.api.formatter.toggle}
                ]
            ]
        };
        var table = $("#table").bootstrapTable(options);
        
        $(document).on("click", ".btn-refresh", function () {
            $("#table").bootstrapTable('refresh');
        });
    });
</script>

